package com.project.design.algorithm;

public class BubbleSorting {

    public Integer[] bubbleSorting(Integer[] str) {
        int len = str.length;
        int count = 0;
        for (int i = 0; i < len - 1; i++) {
            for (int j = 0; j < len - 1 - i; j++) {
                if (str[j] > str[j + 1]) {
                    Integer temp = str[j + 1];
                    str[j + 1] = str[j];
                    str[j] = temp;
                }
                count++;
            }
        }
        System.out.println("循环次数：" + count);
        return str;
    }
}
